#include <QStringList>
#include "molsurfacecontrol.h"
#include "molsurfaceplugin.h"
#include "../../datamanager/proteindatanode.h"

using namespace PBVP;

MolSurfaceControl::MolSurfaceControl(MolSurfacePlugin *pSurfPlugin, QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	m_pSurfPlugin = pSurfPlugin;

	connect(ui.proteinButton, SIGNAL(clicked()), this, SLOT(changeSurfMode()));
	connect(ui.chainButton, SIGNAL(clicked()), this, SLOT(changeSurfMode()));
	connect(ui.ligandButton, SIGNAL(clicked()), this, SLOT(changeSurfMode()));
}

MolSurfaceControl::~MolSurfaceControl()
{

}

void MolSurfaceControl::initialize(ProteinDataNode* pProteinNode)
{
	// ui.proteinButton->setChecked(true);
	ProteinData *pProtein = (ProteinData*)(pProteinNode->data());
	QStringList chainNames = pProtein->getChainNames();
	QStringList ligandNames = pProtein->getLigandNames();
	ui.chainBox->clear();
	ui.ligandBox->clear();
	ui.chainBox->addItems(chainNames);
	ui.ligandBox->addItems(ligandNames);
}

//////////////////////////////////////////////////////////////////////////
// Public slots
//////////////////////////////////////////////////////////////////////////
void MolSurfaceControl::changeSurfMode()
{
	if(ui.proteinButton->isChecked()) {
		m_SurfMode = MolSurfacePlugin::MOL_PROTEIN;
	} else if(ui.chainButton->isChecked()) {
		m_SurfMode = MolSurfacePlugin::MOL_CHAIN;
	} else if(ui.ligandButton->isChecked()) {
		m_SurfMode = MolSurfacePlugin::MOL_LIGAND;
	}
}
